function checkSub()
{
	var fm = document.forms['myform'];
	var ext_mobile = /^(13|15|18)[0-9]{9}$/;
	if(fm['group_name'].value.length==0){
		fm['group_name'].focus();
		alert('战队名称不能为空');
		return false;
	}
	else if(fm['leader_name'].value.length==0){
		fm['leader_name'].focus();
		alert('领队姓名不能为空');
		return false;
	}
	else if(fm['qq'].value.length==0){
		fm['qq'].focus();
		alert('QQ不能为空');
		return false;
	}
	else if(fm['mobile'].value.length==0){
		fm['mobile'].focus();
		alert('联系手机不能为空');
		return false;
	}
	else if(!fm['mobile'].value.match(ext_mobile)){
		fm['mobile'].focus();
		alert('手机号码格式有误');
		return false;
	}
	else if(fm['avatar'].value.length==0){
		fm['avatar'].focus();
		alert('战队头像不能为空');
		return false;
	}
	else{
		return true;
	}
}
/**
 * 用户注册检查
 * @param uname
 * @returns {boolean}
 */
function checkform(){
    //检测用户名是否被注册
    var fm = document.forms['form1'];
    var uname = fm['uname'];
    var pwd = fm['pwd'];
    var pwd2 = fm['pwd2'];
    if(uname.value.length==0){
        uname.focus();
        alert("用户名不能为空");
        return false;
    }
    else if(pwd.value.length==0){
        alert("登录密码不能为空");
        pwd.focus();
        return false;
    }
    else if(pwd2.value.length==0){
        alert("确认密码不能为空");
        pwd2.focus();
        return false;
    }
    else if(pwd.value!=pwd2.value){
        alert("两次密码不一致");
        pwd2.focus();
        return false;
    }
    else
    {
        return true;
    }
}

/**
 * 点击投票
 * @param  {[type]} $gid [description]
 * @return {[type]}      [description]
 */
function subvote(gid)
{
	var rank = $("#rank_"+gid);
    var votenum = parseInt(rank.html());
    $.ajax({
		url: 'subvote/gid/'+gid,
		type: 'GET',
		dataType: 'html',
		success:function(data){
			if(data.indexOf('unlogin')!=-1){
				alert('O(∩_∩)O~~ 亲，登录以后才能投票哦！');
                signin();
			}
			else if(data.indexOf('exist')!=-1){
				alert('o(╯□╰)o 亲，已经投过票了');
			}
            else if(data.indexOf('1')!=-1){
                votenum++;
                rank.html(votenum);
                alert('O(∩_∩)O哇！您是第一个投票哦');
            }
            else if(data.indexOf('2')!=-1){
                votenum++;
                rank.html(votenum);
                alert('O(∩_∩)O~~，投票成功');
            }
            else{
                alert('o(╯□╰)o 投票失败');
            }
		}
	});
}

/**
 * 登录
 * @return {[type]} [description]
 */
function signin(){
	var dialog = art.dialog({id: 'signbox',title: "用户登录",lock:true,fixed:true});
	var template = document.getElementById("signin").innerHTML;
	dialog.content(template);
}

/**
 * 注册
 * @return {[type]} [description]
 */
function signup(){
	var dialog = art.dialog({id: 'signbox',title: "用户注册",lock:true,fixed:true});
	var template = document.getElementById("signup").innerHTML;
	dialog.content(template);
}